/*!
 @header LcbQueuePool.h
 @abstract 线程队列类
 @author 刘成彬
 @version 1.0 2016/05/23 Creation
 */

#import <Foundation/Foundation.h>

#if __has_include("LcbQueuePool.h")
FOUNDATION_EXPORT double LcbQueuePoolVersionNumber;
FOUNDATION_EXPORT const unsigned char LcbQueuePoolVersionString[];
#endif

#ifndef LcbQueuePool_h
#define LcbQueuePool_h

NS_ASSUME_NONNULL_BEGIN

/*!
 @class
 @abstract A dispatch queue pool holds multiple serial queues.
 Use this class to control queue's thread count (instead of concurrent queue).
 */
@interface LcbQueuePool : NSObject
{
    
}
/*!
 @property
 @abstract Pool's name.
 */
@property (nullable, nonatomic, readonly) NSString *name;
/*!
 @method
 @abstract init
 @discussion [self init]
 @result
 */
- (instancetype)init UNAVAILABLE_ATTRIBUTE;
+ (instancetype)new UNAVAILABLE_ATTRIBUTE;

/*!
 @method
 @abstract Creates and returns a dispatch queue pool.
 @discussion [self initWithName:@"" queueCount:@"" qos:@""]
 @param name       The name of the pool.
 @param queueCount Maxmium queue count, should in range (1, 32).
 @param qos        Queue quality of service (QOS).
 @return A new pool, or nil if an error occurs.
 */
- (instancetype)initWithName:(nullable NSString *)name queueCount:(NSUInteger)queueCount qos:(NSQualityOfService)qos;
/*!
 @method
 @abstract  Get a serial queue from pool.
 @discussion [self queue]
 @result
 */
- (dispatch_queue_t)queue;
/*!
 @method
 @abstract defaultPoolForQOS
 @discussion [self defaultPoolForQOS:@""]
 @param qos        Queue quality of service (QOS).
 @result
 */
+ (instancetype)defaultPoolForQOS:(NSQualityOfService)qos;

@end

/// Get a serial queue from global queue pool with a specified qos.
extern dispatch_queue_t LcbQueueGetForQOS(NSQualityOfService qos);

NS_ASSUME_NONNULL_END

#endif
